package com.dp.struts2.yc.channel;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContext;

import org.apache.log4j.Logger;
import org.apache.struts2.util.ServletContextAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.dp.pojo.News;
import com.dp.pojo.NewsVo;
import com.dp.pojo.PageCtrl;
import com.dp.pub.BasePageAction;
import com.dp.pub.SysProperty;
import com.dp.service.jdc.ChannelServiceImpl3;
import com.dp.service.jdc.IndexServiceImpl;
import com.dp.service.jdc.NewsServiceImpl;
import com.dp.vo.TChannels;
/**
 * 新闻信息ACTION
 * 
 */
@Controller
@Scope("session")
public class YcimgAction extends BasePageAction implements ServletContextAware {
	/**
	 * 
	 */
	private static Logger logger = Logger.getLogger(YcimgAction.class);
	private List<TChannels> channelNameList;//新闻所属栏目名称列表
	private List<List<TChannels>> nav2Channels;
	private String navOnChannelId;
	
    private List<TChannels> navChannels ;
    
    private List<TChannels> channelsList;//与同级栏目列表
    
    private List<News> imgNewsList;
    private String channelid;
    
    //分页数据
    private PageCtrl pageCtrl;
    private int pageSize = 8;
    private int pageNo = 0;
    
    @Autowired
    private ChannelServiceImpl3 channelService;
    @Autowired
    private IndexServiceImpl indexService;
    @Autowired
	private NewsServiceImpl newsService;
    
	/**进入新闻内容页面
	 * @author 霍
	 * @param channelNameList//新闻所属栏目名称列表
	 * @param news//新闻内容
	 * 
	 */
    @Deprecated
	public String news(){
	    navChannels = indexService.getChannelsList(SysProperty.getPrep("hdnews_rootch"));
	    nav2Channels = new ArrayList<List<TChannels>>();
	    for (TChannels t : navChannels) {
            List<TChannels> temp = channelService.getLastChannels(t.getChannelId());
            nav2Channels.add(temp);
        }
	    channelsList = channelService.getChannels(channelid);
		channelNameList = newsService.getChannelNames(channelid);
		imgNewsList = channelService.getNews(channelid,pageSize,pageNo);
	    pageCtrl = channelService.getPageCtrl(channelid, pageNo, pageSize);
		return "ycimgnews";
	}
    @Override
	public void setServletContext(ServletContext arg0) {
		// TODO Auto-generated method stub
	}
    public List<TChannels> getChannelNameList() {
        return channelNameList;
    }
    public void setChannelNameList(List<TChannels> channelNameList) {
        this.channelNameList = channelNameList;
    }
    public List<TChannels> getNavChannels() {
        return navChannels;
    }
    public void setNavChannels(List<TChannels> navChannels) {
        this.navChannels = navChannels;
    }
    public List<TChannels> getChannelsList() {
        return channelsList;
    }
    public void setChannelsList(List<TChannels> channelsList) {
        this.channelsList = channelsList;
    }
    public String getChannelid() {
        return channelid;
    }
    public void setChannelid(String channelid) {
        this.channelid = channelid;
    }
    public List<News> getImgNewsList() {
        return imgNewsList;
    }
    public void setImgNewsList(List<News> imgNewsList) {
        this.imgNewsList = imgNewsList;
    }
    public PageCtrl getPageCtrl() {
        return pageCtrl;
    }
    public void setPageCtrl(PageCtrl pageCtrl) {
        this.pageCtrl = pageCtrl;
    }
    public int getPageSize() {
        return pageSize;
    }
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    public int getPageNo() {
        return pageNo;
    }
    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }
    public List<List<TChannels>> getNav2Channels() {
        return nav2Channels;
    }
    public void setNav2Channels(List<List<TChannels>> nav2Channels) {
        this.nav2Channels = nav2Channels;
    }

    public String getNavOnChannelId() {
        return navOnChannelId;
    }
    public void setNavOnChannelId(String navOnChannelId) {
        this.navOnChannelId = navOnChannelId;
    }
}
